package com.myraceengineer;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class SessionsActivity extends Activity {
	
	ListView listView;
	private static int VALID = 4;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.my_list_view);
		
		listView = (ListView) findViewById(R.id.list);
        
        String[] sessions = new String[] { "2014/10/05", 
							        		"2014/09/28",
							        		"2014/09/21",
							        		"2014/09/14"
							               };
        
        ArrayAdapter<String> sessionsAdapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, android.R.id.text1, sessions);
        
        // Assign adapter to ListView
        listView.setAdapter(sessionsAdapter); 
        
     // ListView Item Click Listener
        listView.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view,
               int position, long id) {
            	Intent intent = new Intent(SessionsActivity.this, MapActivity.class);
        	  	startActivity(intent);
            }

        }); 
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}

}
